class Solution:
	# @return a string
	def convert(self, s, nRows):
		strList = []
		for l in xrange(nRows):
			strList.append([])
		i = 0	 # row number
		dirc = 0 # direction 0: down, 1: up
		for c in s:
			strList[i].append(c)
			if dirc == 0:
				i += 1
				if i >= nRows:
					i -= 2
					dirc = 1
			else:
				i -= 1
				if i < 0:
					i += 2
					dirc = 0
		ans = ""
		for string in strList:
			ans += "".join(string)
		return ans

if __name__ == '__main__':
	st = "ABCDEFGHIJKLMN"
	so = Solution()
	ans = so.convert("", 1)
	print ans


